'use strict'
class belike{

  constructor (mdb) {
    this.mdb = mdb || null
  }

  async insert(d) {
    let data=JSON.parse(d)
    //console.log('data数据：',data)
      this.mdb.connect().then(client=>{
        client.query('insert into user_focus values($1::int,$2::int)',[data.userid,data.treeid]).then(res=>{
          return res
        })
      })
        
  }
  async delete(c){
    let data=JSON.parse(c)
    console.log('这是要删除的数据',data)
    this.mdb.connect().then(client=>{
      client.query('delete from user_focus where uid=$1 and treeid=$2',[data.userid,data.treeid]).then(res=>{
        console.log('删除成功')
      })
    })
    return 'delete success'
  }

 
}

module.exports = belike
